﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using NCT.Entity;
using System.ComponentModel;
using NCT.DataAccessComponents;

namespace NCT.MusicApplication
{
    public partial class MainPage : PhoneApplicationPage, INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        public bool ViewCard = false;
        // Constructor
        public MainPage()
        {
       
            InitializeComponent();

          //  (this.Resources["studentBodyPresenter"] as ItemDAC)


            ItemsPreparation itemDAC = (this.Resources["songItemsPresenter"] as ItemsPreparation);
            itemDAC.getSearch(1, 20, "anh", "searchSong");
            //(this.Resources["studentBodyPresenter"] as StudentDAC).LoadData();
          
        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            //if (ViewCard)
            //{
                
            //    Grid.SetRow(ContentPanelListCard, 1);
            //    Grid.SetRow(ContentPanelList, 2);
            //}
            //else
            //{
            //    Grid.SetRow(ContentPanelList, 1);
            //    Grid.SetRow(ContentPanelListCard, 2);
            //}
            //ViewCard = !ViewCard;


            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("chang view"));
            }



        }

        private void itemControl_Navigation(object sender, NavigationListControl.NavigationEventArgs e)
        {
            FrameworkElement root = Application.Current.RootVisual as FrameworkElement;
            root.DataContext = e.Item;

            Item item = e.Item as Item;
            switch (item.Type)
            {
                case ("song"):
                    NavigationService.Navigate(new Uri("/PlaySongPage.xaml", UriKind.RelativeOrAbsolute));
                    break;
                case ("mv"):
                    NavigationService.Navigate(new Uri("/PlaySongPage.xaml", UriKind.RelativeOrAbsolute));
                    break;              
                default:
                    return;
            }
        }
    }
}